Add API test for MongoDB SSL remote instance registration - #1292
Add API test for MongoDB SSL remote instance registration#1292peterSirotnak wants to merge 1 commit into
Conversation
Recreate tests/api/remoteInstances/mongoDb.test.ts with a valid AddMongoDBServiceParams body. The previous version returned HTTP 400 because pmm_agent_id (a required field, validate min_len=1) was omitted, and it used schema='https' (not a MongoDB param) instead of tls=true, with a wrong client-cert path. Mirror the proven working configuration: set pmm_agent_id, tls=true, tls_skip_verify, authentication_mechanism MONGODB-X509, and read certs from /mongodb_certs inside the psmdb-server container. Poll that the service agents are running after adding the instance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0179HcG7YKEKi78Ztmta5EbN Signed-off-by: Claude <peter.sirotnak@percona.com>
| pmmTest( | ||
| 'PMM-T948 Verify adding MongoDB SSL services remotely via API before upgrade @pre-upgrade', | ||
| async ({ api, cliHelper }) => { | ||
| const ca = cliHelper | ||
| .execSilent(`docker exec ${container} cat /mongodb_certs/ca-certs.pem`) | ||
| .assertSuccess().stdout; | ||
| const clientCert = cliHelper | ||
| .execSilent(`docker exec ${container} cat /mongodb_certs/client.pem`) | ||
| .assertSuccess().stdout; | ||
|
|
||
| const data: AddRemoteInstance = { | ||
| mongodb: { | ||
| add_node: { node_name: 'psmdb_ssl_remote_upgrade_node', node_type: 'NODE_TYPE_REMOTE_NODE' }, | ||
| address: container, | ||
| authentication_mechanism: 'MONGODB-X509', | ||
| cluster: 'mongodb_ssl_remote_cluster', | ||
| pmm_agent_id: 'pmm-server', | ||
| port: '27017', | ||
| qan_mongodb_profiler: true, | ||
| service_name: remoteServiceName, | ||
| tls: true, | ||
| tls_ca: ca, | ||
| tls_certificate_file_password: '', | ||
| tls_certificate_key: clientCert, | ||
| tls_skip_verify: true, | ||
| }, | ||
| }; | ||
|
|
||
| await api.remoteInstanceApi.addRemoteInstance(data); | ||
|
|
||
| await expect | ||
| .poll(() => api.inventoryApi.verifyAgentsAreRunning(remoteServiceName), { | ||
| message: `One or more agents are not running for ${remoteServiceName}`, | ||
| timeout: Timeouts.TWO_MINUTES, | ||
| }) | ||
| .toBe(true); | ||
| }, | ||
| ); |
There was a problem hiding this comment.
🔴 This is a second copy of a test that already exists on the base branch: e2e_tests/tests/upgrade/ssl.test.ts:11 is PMM-T948 + PMM-T947 - Verify Adding MongoDB SSL service remotely via API before upgrade @pre-upgrade, with the same psmdb-server container, the same MONGODB-X509 payload, the same cluster name and the same verifyAgentsAreRunning poll — only the CA lookup and the service name differ.
Both are tagged @pre-upgrade, so upgrade-pmm-runner.yml:205 (--grep "@pre-upgrade") now registers two remote MongoDB SSL services and runs PMM-T948 twice, and the Zephyr case reports against two results. The new service psmdb_ssl_remote_upgrade_service also has no post-upgrade counterpart — ssl.test.ts:50 only verifies metrics for remote_api_psmdb-server — so it adds pre-upgrade work that nothing checks afterwards.
The head commit message says "Fix MongoDB SSL remote API test (PMM-T948)", and reading the CA from docker exec … cat /mongodb_certs/ca-certs.pem instead of find / -name "ca.crt" (ssl.test.ts:16-21) is that fix. Apply it in place in ssl.test.ts and drop this file.
| .execSilent(`docker exec ${container} cat /mongodb_certs/client.pem`) | ||
| .assertSuccess().stdout; | ||
|
|
||
| const data: AddRemoteInstance = { |
There was a problem hiding this comment.
🔴 Lint is red on this head SHA because of this line — Lint run 33617968709:
/home/runner/work/pmm-qa/pmm-qa/e2e_tests/tests/api/remoteInstances/mongoDb.test.ts
20:7 error Unexpected blank line before this statement @stylistic/padding-line-between-statements
The other six errors in that job are pre-existing on the base branch; this one is the PR's. npm run lint -- --fix in e2e_tests clears it.
| const remoteServiceName = 'psmdb_ssl_remote_upgrade_service'; | ||
|
|
||
| pmmTest( | ||
| 'PMM-T948 Verify adding MongoDB SSL services remotely via API before upgrade @pre-upgrade', |
There was a problem hiding this comment.
🔵 Title is missing the separator: the convention is PMM-Txxxx - description (e2e_tests/CONTRIBUTING.md:70), which every other upgrade test follows, including the existing PMM-T948 one. If this test survives the thread above, make it PMM-T948 - Verify adding ….
|
🟡 This PR targets |
Add end-to-end API test to verify MongoDB SSL services can be added remotely via the PMM API before upgrade.
Changes:
e2e_tests/tests/api/remoteInstances/mongoDb.test.tsthat validates remote MongoDB instance registration with SSL/TLS configurationTest Details:
@pre-upgradeto run before upgrade scenarioshttps://claude.ai/code/session_0179HcG7YKEKi78Ztmta5EbN